/*
  Author:		Damian Esteves
  Project Page:	http://code.google.com/p/snespadplus/
  Based on: 	SNESpad http://code.google.com/p/nespad/
  
  SNESPadPlus is an Arduino library for interfacing with one or two SNES controllers.
  It is based on the SNESpad library under rights granted by the GPL v3.
  
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
  (at your option) any later version.

  This program is distributed without any warranty, even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
*/

#ifndef SNESPadPlus_h
#define SNESPadPlus_h

#include <inttypes.h>

#define SNES_B       0x01
#define SNES_Y       0x02
#define SNES_SELECT  0x04
#define SNES_START   0x08
#define SNES_UP      0x10
#define SNES_DOWN    0x20
#define SNES_LEFT    0x40
#define SNES_RIGHT   0x80
#define SNES_A       0x100
#define SNES_X       0x200
#define SNES_L       0x400
#define SNES_R       0x800
#define SNES2_B      0x10000
#define SNES2_Y      0x20000
#define SNES2_SELECT 0x40000
#define SNES2_START  0x80000
#define SNES2_UP     0x100000
#define SNES2_DOWN   0x200000
#define SNES2_LEFT   0x400000
#define SNES2_RIGHT  0x800000
#define SNES2_A      0x1000000
#define SNES2_X      0x2000000
#define SNES2_L      0x4000000
#define SNES2_R      0x8000000


class SNESPadPlus {

  public:
	SNESPadPlus(int strobe, int clock, int data);
    SNESPadPlus(int strobe, int clock, int data, int data2);
	int buttons();
    unsigned long buttons2();

  private:
    void strobe();
	int shiftIn();
    unsigned long shiftIn2();
    int m_strobe, m_clock, m_data, m_data2;

};

#endif

